<?php

namespace App\Edu\Models;

use App\Models\ApiSoftDeletes;
use App\Models\BaseModel;

class EduCourseModel extends BaseModel
{
    use ApiSoftDeletes;
    protected $table = 'edu_course';

    /** 
     * 获取列表
     */
    public function getList($query, $pageSize = 10)
    {
        $db = $this->db('a');
        $where = [
        ];

        $fields = "a.*";
        
        $model = $db
            ->where($where)
            ->where('a.status', '<>', 2)
            ->selectRaw($fields);
        $orderByRaw = 'a.id desc';
        if (!empty($query['order_by'])) {
            $orderByRaw = "a." . $query['order_by'];
        }
        $pageData = $model
            ->orderByRaw($orderByRaw)
            ->paginate($pageSize)
            ->toArray();
        return $pageData;
    }
}
